package com.office.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.office.common.annotation.Log;
import com.office.common.core.controller.BaseController;
import com.office.common.core.domain.AjaxResult;
import com.office.common.enums.BusinessType;
import com.office.system.domain.SysStockRecords;
import com.office.system.service.ISysStockRecordsService;
import com.office.common.utils.poi.ExcelUtil;
import com.office.common.core.page.TableDataInfo;

/**
 * 入库记录管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-17
 */
@RestController
@RequestMapping("/system/records")
public class SysStockRecordsController extends BaseController
{
    @Autowired
    private ISysStockRecordsService sysStockRecordsService;

    /**
     * 查询入库记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysStockRecords sysStockRecords)
    {
        startPage();
        List<SysStockRecords> list = sysStockRecordsService.selectSysStockRecordsList(sysStockRecords);
        return getDataTable(list);
    }

    /**
     * 导出入库记录管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:records:export')")
    @Log(title = "入库记录管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysStockRecords sysStockRecords)
    {
        List<SysStockRecords> list = sysStockRecordsService.selectSysStockRecordsList(sysStockRecords);
        ExcelUtil<SysStockRecords> util = new ExcelUtil<SysStockRecords>(SysStockRecords.class);
        util.exportExcel(response, list, "入库记录管理数据");
    }

    /**
     * 获取入库记录管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:records:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return success(sysStockRecordsService.selectSysStockRecordsByRecordId(recordId));
    }

    /**
     * 新增入库记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:records:add')")
    @Log(title = "入库记录管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysStockRecords sysStockRecords)
    {
        return toAjax(sysStockRecordsService.insertSysStockRecords(sysStockRecords));
    }

    /**
     * 修改入库记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:records:edit')")
    @Log(title = "入库记录管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysStockRecords sysStockRecords)
    {
        return toAjax(sysStockRecordsService.updateSysStockRecords(sysStockRecords));
    }

    /**
     * 删除入库记录管理
     */
    @PreAuthorize("@ss.hasPermi('system:records:remove')")
    @Log(title = "入库记录管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(sysStockRecordsService.deleteSysStockRecordsByRecordIds(recordIds));
    }
}
